package com.shelpe.services.sinbad.entity.mongo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shelpe.services.sinbad.entity.jpa.Campaign;

import lombok.Data;

@Data
@Document(collection = "keyword_delete_error_logs")
public class KeywordDeleteErrorLog {
	@Id
	private String id;
	@Indexed
	private long userID;
	@Indexed
	private long adgroupID;
	@Indexed
	private long campaignID;
	@Indexed
	private Date executeTime;
	@Indexed
	private String subCode;
	@Indexed
	private String subMessage;
	private String errorCode;
	private List<Long> words;
	
	private String res;

	public void from(Campaign campaign) {
		this.userID = campaign.getUserID();

		this.executeTime = new Date();
		this.id = this.userID + "_" + this.executeTime.getTime();
	}

	public void addKeyWordID(long keywordID) {
		if (this.words == null) {
			this.words = new ArrayList<Long>();
		}
		this.words.add(keywordID);
	}
}
